/**
 * tzdesk系统平台
 * moonvip_admin
 * com.tz.web.bookcomment
 * BookCommentController.java
 * 创建人:Marlon
 * 时间：2016年08月28日 19:07:05
 * 2015潭州教育公司-版权所有
 */
package com.tz.web.bookcomment;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.servlet.ModelAndView;

import com.tz.bean.BookComment;
import com.tz.bean.TzParams;
import com.tz.service.bookcomment.IBookCommentService;

/**
 * 评论留言web
 * BookCommentController
 * 创建人:Marlon
 * 时间：2016年08月28日 19:07:05
 * @version 1.0.0
 * 
 */
@Controller
@RequestMapping("/stage/bookcomment")
public class BookCommentController {
	
	@Autowired
	private IBookCommentService bookcommentService;
	
	@ResponseBody
	@RequestMapping(value="/save",method=RequestMethod.POST)
	public String save(BookComment bookComment){
		System.out.println(bookComment);
		bookcommentService.save(bookComment);
		if(bookComment.getId()>0){
			return "success";
		}else {
			return "fail";
		}
	}
	
	/*列表查询*/
	@RequestMapping("/list")
	public String list(TzParams params){
		return "bookcomment/list";
	}
	
	/*模板页面*/
	@RequestMapping("/template")
	public ModelAndView template(TzParams params){
		ModelAndView modelAndView = new ModelAndView();
		List<BookComment> bookcomments = bookcommentService.findBookComments(params);
		int count = bookcommentService.count(params);
		modelAndView.setViewName("bookcomment/template");
		modelAndView.addObject("datas",bookcomments);
		modelAndView.addObject("itemCount",count);
		return modelAndView;
	}
}
